import { createRouter, createWebHistory } from 'vue-router';
import Home from '@/views/Home.vue';
import Video from "@/views/Video.vue";
import Center from "@/views/Center.vue";
import Mall from "@/views/Mall.vue";
import Commodity from '@/views/Commodity.vue';
import Login from "@/views/Login.vue";
import ManageHome from '@/views/manage/home.vue';
import ManageLogin from '@/views/manage/login.vue';

const routes = [
  {
    path: '/',
    redirect: 'home'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    beforeEnter: (to, from, next) => {
      var apps = document.querySelector('#app')
      apps.style = ''
      next();
    }
  },
  {
    path: '/login',
    name: 'Login',
    component: Login,
    beforeEnter: (to, from, next) => {
      var apps = document.querySelector('#app')
      apps.style = ''
      next();
    }
  },
  {
    path: '/video',
    name: 'Video',
    component: Video,
    beforeEnter: (to, from, next) => {
      var apps = document.querySelector('#app')
      apps.style = ''
      next();
    },
  },
  {
    path: '/mall',
    name: 'Mall',
    component: Mall,
    beforeEnter: (to, from, next) => {
      var apps = document.querySelector('#app')
      apps.style = ''
      next();
    },
  },
  {
    path: '/center',
    name: 'Center',
    component: Center,
    beforeEnter: (to, from, next) => {
      var apps = document.querySelector('#app')
      apps.style = ''
      next();
    }
  },
  {
    path: '/commodity',
    name: 'Commodity',
    component: Commodity,
    beforeEnter: (to, from, next) => {
      var apps = document.querySelector('#app')
      apps.style = ''
      next();
    }
  },
  {
    path: '/manage/login',
    name: 'ManageLogin',
    component: ManageLogin,
    beforeEnter: (to, from, next) => {
      var apps = document.querySelector('#app')
      apps.style = ''
      next();
    }
  },
  {
    path: '/manage/home',
    name: 'ManageHome',
    component: ManageHome,
    beforeEnter: (to, from, next) => {
      var apps = document.querySelector('#app')
      apps.style = ''
      next();
    }
  }
];

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
});

export default router;
